
<%@ page import = "clothing.database.OrderManager" %>
<%@ page import = "clothing.database.Order" %>
<%@ page import = "clothing.database.Supplier" %>
<%@ page import = "clothing.database.SupplierManager" %>
<%@ page import = "java.util.ArrayList" %>

<%@ include file = "templates/header.jsp" %>


<script src = "CalendarPopup.js" type = "text/javascript"></script>
<script>
var cal18 = new CalendarPopup("testdiv1");
cal18.setCssPrefix("TEST");
 </script>
 


<h3>Order Page</h3>






<STYLE>
	.TESTcpYearNavigation,
	.TESTcpMonthNavigation
			{
			background-color:#6677DD;
			text-align:center;
			vertical-align:center;
			text-decoration:none;
			color:#FFFFFF;
			font-weight:bold;
			}
	.TESTcpDayColumnHeader,
	.TESTcpYearNavigation,
	.TESTcpMonthNavigation,
	.TESTcpCurrentMonthDate,
	.TESTcpCurrentMonthDateDisabled,
	.TESTcpOtherMonthDate,
	.TESTcpOtherMonthDateDisabled,
	.TESTcpCurrentDate,
	.TESTcpCurrentDateDisabled,
	.TESTcpTodayText,
	.TESTcpTodayTextDisabled,
	.TESTcpText
			{
			font-family:arial;
			font-size:8pt;
			}
	TD.TESTcpDayColumnHeader
			{
			text-align:right;
			border:solid thin #6677DD;
			border-width:0 0 1 0;
			}
	.TESTcpCurrentMonthDate,
	.TESTcpOtherMonthDate,
	.TESTcpCurrentDate
			{
			text-align:right;
			text-decoration:none;
			}
	.TESTcpCurrentMonthDateDisabled,
	.TESTcpOtherMonthDateDisabled,
	.TESTcpCurrentDateDisabled
			{
			color:#D0D0D0;
			text-align:right;
			text-decoration:line-through;
			}
	.TESTcpCurrentMonthDate
			{
			color:#6677DD;
			font-weight:bold;
			}
	.TESTcpCurrentDate
			{
			color: #FFFFFF;
			font-weight:bold;
			}
	.TESTcpOtherMonthDate
			{
			color:#808080;
			}
	TD.TESTcpCurrentDate
			{
			color:#FFFFFF;
			background-color: #6677DD;
			border-width:1;
			border:solid thin #000000;
			}
	TD.TESTcpCurrentDateDisabled
			{
			border-width:1;
			border:solid thin #FFAAAA;
			}
	TD.TESTcpTodayText,
	TD.TESTcpTodayTextDisabled
			{
			border:solid thin #6677DD;
			border-width:1 0 0 0;
			}
	A.TESTcpTodayText,
	SPAN.TESTcpTodayTextDisabled
			{
			height:20px;
			}
	A.TESTcpTodayText
			{
			color:#6677DD;
			font-weight:bold;
			}
	SPAN.TESTcpTodayTextDisabled
			{
			color:#D0D0D0;
			}
	.TESTcpBorder
			{
			border:solid thin #6677DD;
			}
</STYLE>






<script>
function process(a)
{
	document.getElementById('id').value = a;
	document.myform.submit();
}  
</script>
<%@ include file="templates/main_nav.jsp" %>
<%
	OrderManager om = new OrderManager();
	ArrayList<Order> list = om.getList();
	
	out.println("<form name =\"myform\" id=\"myform\" action =\"changeStatusOrder.jsp\" method=\"post\">");
	out.println("<table>");
	%>
	<tr>
	Pending Orders:
		<td><strong>Supplier ID</strong></td>
		<td><strong>Order ID</strong></td>
		<td><strong>Order Date</strong></td>
		<td><strong>Delivery Day</strong></td>
		<td><strong>Status</strong></td>
	</tr>
	<% 
	
	for(int i=0;i<list.size();i++)
	{
		
		
		out.println("<tr>");Order current = list.get(i);
		System.out.println(i+"  "+ current.getStatus());
		//Order current = list.get(i);
		if (current.getStatus().equals("Awaiting Arrival")){
			out.println("<td>"+ current.getSupplierId()+"</td>");
			out.println("<td>"+ current.getOrderId()+"</td>");
			out.println("<td>"+ current.getOrderDate()+"</td>");
			out.println("<td>"+ current.getExpectedD()+"</td>");
			out.println("<td>"+ current.getStatus()+"</td>");
			
			%>
			
			<td><input type="button" value ="Change Status" onclick = "process(<%=current.getOrderId() %>);" /></td>
			<%
			
		}
		    
		%>
		<input type="hidden" name ="id" id = "id" />
	<% 
			 
		out.println("</tr>");
	}
	out.println("</table></form>");
%>
<table>
<tr>
	Arrived Orders:
		<td><strong>Supplier ID</strong></td>
		<td><strong>Order ID</strong></td>
		<td><strong>Order Date</strong></td>
		<td><strong>Delivery Day</strong></td>
		<td><strong>Status</strong></td>
	</tr>
	<% 
	
	for(int i=0;i<list.size();i++)
	{
		
		
		out.println("<tr>");
		Order current = list.get(i);
		if (current.getStatus().equals("Arrived")){
			out.println("<td>"+ current.getSupplierId()+"</td>");
			out.println("<td>"+ current.getOrderId()+"</td>");
			out.println("<td>"+ current.getOrderDate()+"</td>");
			out.println("<td>"+ current.getExpectedD()+"</td>");
			out.println("<td>"+ current.getStatus()+"</td>");		}
%>

<%
	out.println("</tr>");
	}

	out.println("</table></form>");
%>
<h2>Add an Order</h2>
<form action="addOrder.jsp" method="post" name="example">
<table style="float:left">
	<tr>
		<td>Supplier ID: </td>
            <td>
                 <select name="supplier_id" />
                 <% 
                 out.println("<option> Please Select </option>");
                SupplierManager sm =  new SupplierManager();
                ArrayList<Supplier> listE = sm.getList();
                for(int i=0;i<listE.size();i++)
            	{
            		Supplier current = listE.get(i);
            		int SIDs = current.getId();
            		String ID = Integer.toString(SIDs);
            	    out.println("<option value=\""+ID+"\">"+ ID+"</option>");
            	}
                
                
                %>
                 </select>
            </td>
	</tr>

	<tr>
		<td>Order Date:</td>
		<td><input type="Text" name="order_date" />
		<A HREF="#"
   onClick="cal18.select(document.forms['example'].order_date,'anchor1','MM/dd/yyyy'); return false;"
   NAME="anchor1" ID="anchor1">select</A>

		</td>
	</tr>

	<tr>
			<td>Expected Delivery Day: </td>
			<td><input type="text" name="expectedD" />
			<A HREF = "#"
			onClick = "cal18.select(document.forms['example'].expectedD, 'anchor1', 'MM/dd/yyyy'); return false;"
				NAME = "anchor1" ID = "anchor1">select </A>
			</td>
		</tr>
       <tr>
			<td>Status: </td>
                    <td><select name="status">
                     <option selected="selected"/> Please Select</option>
                     <option  value="Arrived"/> Arrived</option>
                     <option  value="Awaiting Arrival"/> Awaiting Arrival</option>
                    </select></td>
		</tr>


	<tr>
		<td></td>
		<td><input type="submit" value="submit" /></td>
	</tr>
</table>
   <div id = "testdiv1"></div>
</form>


<%@ include file="templates/footer.jsp"%>
